]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dateMenu: Hide "Open Calendar" item if calendar unavailable
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 12 Oct 2012 18:59:31 +0000 (20:59 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 13 Oct 2012 12:40:51 +0000 (14:40 +0200)
The configured calendar application might not actually be installed.
Instead of failing with an error message, hide the menu item altogether
in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=686050

js/ui/dateMenu.js

index 7f01a76150004c5f228978b11ce303ff92619b9d..7b762b3de98934016f1bf52b7266fa6132d2c1a1 100644 (file)
@@ -113,6 +113,11 @@ const DateMenuButton = new Lang.Class({
         this._openCalendarItem.actor.can_focus = false;
         vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
 
+        this._calendarSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.office.calendar' });
+        this._calendarSettings.connect('changed::exec',
+                                       Lang.bind(this, this._calendarSettingsChanged));
+        this._calendarSettingsChanged();
+
         // Whenever the menu is opened, select today
         this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
             if (isOpen) {
@@ -146,6 +151,12 @@ const DateMenuButton = new Lang.Class({
         this._sessionUpdated();
     },
 
+    _calendarSettingsChanged: function() {
+        let exec = this._calendarSettings.get_string('exec');
+        let fullExec = GLib.find_program_in_path(exec);
+        this._openCalendarItem.actor.visible = fullExec != null;
+    },
+
     _setEventsVisibility: function(visible) {
         this._openCalendarItem.actor.visible = visible;
         this._separator.visible = visible;
@@ -194,14 +205,13 @@ const DateMenuButton = new Lang.Class({
 
     _onOpenCalendarActivate: function() {
         this.menu.close();
-        let calendarSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.office.calendar' });
-        let tool = calendarSettings.get_string('exec');
+        let tool = this._calendarSettings.get_string('exec');
         if (tool.length == 0 || tool.substr(0, 9) == 'evolution') {
             // TODO: pass the selected day
             let app = Shell.AppSystem.get_default().lookup_app('evolution-calendar.desktop');
             app.activate();
         } else {
-            let needTerm = calendarSettings.get_boolean('needs-term');
+            let needTerm = this._calendarSettings.get_boolean('needs-term');
             if (needTerm) {
                 let terminalSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.terminal' });
                 let term = terminalSettings.get_string('exec');